<!DOCTYPE HTML>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=yes,email=no,date=no,address=no">
		<title>我的</title>
		<link rel="stylesheet" type="text/css" href="${ctxPath}/static/assets/aui/css/aui.css" />
		<script type="text/javascript" src="${ctxPath}/static/assets/aui/script/aui-dialog.js" ></script>
		<!-- jQuery Include -->
		<script type="text/javascript" src="${ctxPath}/static/assets/scripts/jquery.min.js"></script>

        <style>
            .text-white {
                color: #ffffff !important;
            }

            .aui-grid [class*=aui-col-] {
                padding: 0.75rem 0;
            }
            #aui-content{
                margin-top: 40px;
            }
        </style>
	</head>

	<body>
		<!-- 顶部 -->
		<section class="aui-content" id="user-info">
			<div class="aui-list aui-media-list aui-list-noborder aui-bg-info">
				<div class="aui-list-item aui-list-item-middle">
					<div class="aui-media-list-item-inner ">
						<div style="display: none" id="img" class="aui-list-item-media" style="width:3rem;">
							<img id="pic" style="border-radius: 50%;border:2px solid #03a9f4;width: 70px;height: 70px;" src="${ctxPath}/static/assets/images/timg.jpg" class="aui-img-round">
							<input id="upload" name="file" accept="image/*" type="file" style="display: none">
						</div>
						<div class="aui-list-item-inner aui-list-item-arrow" id="eidtInfo">
							<div class="aui-list-item-text text-white aui-font-size-18" id='user-name'>陈老板</div>
							<div class="aui-list-item-text text-white">
								<div>
								<i class="aui-iconfont aui-icon-mobile aui-font-size-14"></i><span id='user-phone' >152****0989</span></div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</section>
		<section class="aui-content" id="aui-content">
			<ul class="aui-list aui-list-in aui-margin-b-15">
				<li class="aui-list-item" id="toPayLogs" onclick="toCoupon()">
					<div class="aui-list-item-label-icon">
						<i class="aui-iconfont aui-icon-cert aui-text-warning"></i>
					</div>
					<div class="aui-list-item-inner aui-list-item-arrow" >
						<div class="aui-list-item-title">优惠券</div>
					</div>
				</li>
				<li class="aui-list-item" onclick="toCollection()">
					<div class="aui-list-item-label-icon">
						<i class="aui-iconfont aui-icon-star aui-text-warning"></i>
					</div>
					<div class="aui-list-item-inner aui-list-item-arrow" >
						<div class="aui-list-item-title">我的收藏</div>
					</div>
				</li>
				<li class="aui-list-item"  onclick="toNotice()">
					<div class="aui-list-item-label-icon">
						<i class="aui-iconfont aui-icon-comment aui-text-warning"></i>
					</div>
					<div class="aui-list-item-inner aui-list-item-arrow" >
						<div class="aui-list-item-title">通知</div>
					</div>
				</li>
				<li class="aui-list-item" onclick="callme()">
					<div class="aui-list-item-label-icon">
						<i class="aui-iconfont aui-icon-phone aui-text-primary"></i>
					</div>
					<div class="aui-list-item-inner aui-list-item-arrow" >
						<a href="tel:15982276786" style="color: black">联系客服</a>
					</div>
				</li>
				<li class="aui-list-item"  onclick="toSetting()">
					<div class="aui-list-item-label-icon">
						<i class="aui-iconfont aui-icon-gear aui-text-warning"></i>
					</div>
					<div class="aui-list-item-inner aui-list-item-arrow" >
						<div class="aui-list-item-title">设置</div>
					</div>
				</li>
				<li class="aui-list-item" onclick="toQuestion()">
					<div class="aui-list-item-label-icon">
						<i class="aui-iconfont aui-icon-question aui-text-warning"></i>
					</div>
					<div class="aui-list-item-inner aui-list-item-arrow" >
						<div class="aui-list-item-title">问题和反馈</div>
					</div>
				</li>
				<li class="aui-list-item">
					<div class="aui-list-item-label-icon">
						<i class="aui-iconfont aui-icon-trash aui-text-danger"></i>
					</div>
					<div class="aui-list-item-inner aui-list-item-arrow" id="exit">
						<div class="aui-list-item-title">退出系统</div>
					</div>
				</li>
			</ul>
		</section>
		<footer class="aui-bar aui-bar-tab" id="footer">
			<div class="aui-bar-tab-item" onclick="examinePage()">
				<i class="aui-iconfont aui-icon-paper"></i>
				<div class="aui-bar-tab-label">周边服务</div>
			</div>
			<div class="aui-bar-tab-item" onclick="artificerPage()">
				<i class="aui-iconfont aui-icon-menu"></i>
				<div class="aui-bar-tab-label">技师列表</div>
			</div>
			<div class="aui-bar-tab-item" onclick="orderPage()">
				<i class="aui-iconfont aui-icon-cart"></i>
				<div class="aui-bar-tab-label">订单列表</div>
			</div>
			<div class="aui-bar-tab-item aui-active" onclick="minePage()">
				<i class="aui-iconfont aui-icon-my"></i>
				<div class="aui-bar-tab-label">我的</div>
			</div>
		</footer>
	</body>
<script type="text/javascript" src="${ctxPath}/static/assets/aui/script/api.js"></script>
	<script type="text/javascript" src="${ctxPath}/static/assets/aui/script/aui-toast.js"></script>
<script type="text/javascript">
	apiready = function() {}
</script>
<script type="text/javascript">
	var  user=localStorage.getItem("userInfo");//以“key”为名称存储一个值“value”
	if(!user){
		location.href="${ctxPath}/wechat/public/toLoginPage";//未实现
	}
	var obj = JSON.parse(user); // --> parse error
	$(function(){
		$("#img").show();
		if(!obj.consumerPict)
			$("#pic").attr("src","${ctxPath}/static/assets/images/timg.jpg");
		else
			$("#pic").attr("src","http://www.tyler.org.cn/"+obj.consumerPict);

		$('#user-name').text(obj.name);
		$('#user-phone').text(obj.phone.replace(obj.phone.substr(3,5),"*****"));
		$("#exit").click(function(){
			exit(obj);
		})

	})

	function  exit(user){
		var dialog = new auiDialog({})
		dialog.alert({
			title:"提示",
			msg:'是否退出系统',
			buttons:['取消','确定']
		},function(ret){
			if(ret.buttonIndex==2){
				//回调函数
				$.ajax({
					type: "POST",
					url: "${ctxPath}/wx/small/loginOut",
					data: {
						phone: user.phone
					},
					dataType: "json",
					success: function (result) {
						if (result.status == "0000") {
							location.href="${ctxPath}/wechat/public/toLoginPage";//未实现
							localStorage.clear();//清空所有cookie信息
						}
					}
				});
			}
		})
	}

	function  artificerPage(){
		location.href="${ctxPath}/wechat/public/toArtificerListPage";
	}
	function  examinePage(){
		location.href ="${ctxPath}/wechat/public/toPeripheryPage";
	}
	function  orderPage(){
		location.href ="${ctxPath}/wechat/public/toOrderPage";
	}

	$("#eidtInfo").click(function(){
		location.href ="${ctxPath}/wechat/public/editInfo";
	});

	//上传头像
	$(function() {
		$("#pic").click(function() {
			$("#upload").click(); //隐藏了input:file样式后，点击头像就可以本地上传
			$("#upload").on("change", function() {
				var objUrl = getObjectURL(this.files[0]); //获取图片的路径，该路径不是图片在本地的路径
				if (objUrl) {
					// $("#pic").attr("src", objUrl); //将图片路径存入src中，显示出图片
					upimg();
				}
			});
		});
	});

	//建立一?可存取到?file的url
	function getObjectURL(file) {
		var url = null;
		if (window.createObjectURL != undefined) { // basic
			url = window.createObjectURL(file);
		} else if (window.URL != undefined) { // mozilla(firefox)
			url = window.URL.createObjectURL(file);
		} else if (window.webkitURL != undefined) { // webkit or chrome
			url = window.webkitURL.createObjectURL(file);
		}
		return url;
	}
	//上传头像到服务器
	function upimg() {
		var pic = $('#upload')[0].files[0];
		var file = new FormData();
		file.append('file', pic);
		file.append('userType','0');
		file.append('id',obj.id);
		$.ajax({
			url: "${ctxPath}/upload/oss/image",
			type: "post",
			data: file,
			cache: false,
			contentType: false,
			processData: false,
			success: function(result) {
				if (result.status == "0000") {
					obj.consumerPict=result.data;
					localStorage.setItem("userInfo",JSON.stringify(obj));//以“key”为名称存储一个值“value”
					$("#img>img").attr("src","http://www.tyler.org.cn/"+result.data+"?x-oss-process=image/crop,x_10,y_10,w_1100,h_1100,g_center");
				}

			}
		});
	}

	//去优惠券的页面
	function toCoupon(){
		location.href="${ctxPath}/wechat/public/toCoupon";
	}
	//去收藏的页面
	function toCollection(){
		location.href="${ctxPath}/wechat/public/toCollection";
	}
	//去通知页面
	function toNotice(){
		location.href="${ctxPath}/wechat/public/toNotice";
	}
	//去问题和反馈页面
	function toQuestion(){
		location.href="${ctxPath}/wechat/public/toQuestion";
	}

	// 去设置页面
	function toSetting(){
		apiready = function(){
			api.parseTapmode();
		}
		var toast = new auiToast({
		})
		toast.custom({
			title:"暂没开放此功能",
			html:'<i class="aui-iconfont aui-icon-question"></i>',
			duration:2000
		});
	}
	//联系我们
	function callme() {
		window.location.href="tel:15982276786";
	}
</script>
</html>